#!/bin/sh

#
# Test writing a resource to an offset
#

. "$(cd "$(dirname "$0")" && pwd)/common.sh"
create_15M_file

cat >$CONFIG <<EOF
file-resource subdir/TEST {
        host-path = "${TESTFILE_15M}"
}

task complete {
	on-resource subdir/TEST { raw_write(1) }
}
EOF

# Create the firmware file, then "burn it"
$FWUP_CREATE -c -f $CONFIG -o $FWFILE
$FWUP_APPLY -a -d $IMGFILE -i $FWFILE -t complete

# Check that the 15 MB file ended up in the right place.
cmp_bytes 15000000 $TESTFILE_15M $IMGFILE 0 512

# Check that the verify logic works on this file
$FWUP_VERIFY -V -i $FWFILE
